Skip to content

feat: paginate /codes with prev/next buttons#32

Merged
BigMichi1 merged 1 commit into
mainfrom
feat/codes-pagination
May 17, 2026
Merged

feat: paginate /codes with prev/next buttons#32
BigMichi1 merged 1 commit into
mainfrom
feat/codes-pagination

Conversation

@BigMichi1
Copy link
Copy Markdown
Owner

  • Remove the count option from /codes (was capped at 20)
  • Add getRedeemedCodeCount() to codeManager for total page calculation
  • Add offset parameter to getRedeemedCodeDetails() for slicing
  • Build pages of 5 codes with disabled-aware ◀ Prev / Next ▶ buttons
  • Button custom IDs encode the owner's Discord ID so only they can page
  • Handle button interactions in bot.ts via a dedicated InteractionCreate listener
  • Add tests: limit, offset/pagination, count (8 new tests, 169 pass total)

- Remove the count option from /codes (was capped at 20)
- Add getRedeemedCodeCount() to codeManager for total page calculation
- Add offset parameter to getRedeemedCodeDetails() for slicing
- Build pages of 5 codes with disabled-aware ◀ Prev / Next ▶ buttons
- Button custom IDs encode the owner's Discord ID so only they can page
- Handle button interactions in bot.ts via a dedicated InteractionCreate listener
- Add tests: limit, offset/pagination, count (8 new tests, 169 pass total)

Signed-off-by: Michael Cramer <michael@bigmichi1.de>
Copilot AI review requested due to automatic review settings May 17, 2026 08:15
@github-actions
Copy link
Copy Markdown

✅ Coverage Report

Metric Value
Current coverage 54.44% (938/1723)
Baseline coverage 54.23% (930/1715)
Result PASS

Changed Files

File Baseline Current Status
src/bot/bot.ts N/A N/A SKIP (new to coverage)
src/bot/commands/codes.ts N/A N/A SKIP (new to coverage)
src/bot/database/codeManager.test.ts SKIP (ignored)
src/bot/database/codeManager.ts 77.18% 77.91% PASS

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Replaces the count option on /codes with proper Discord pagination using Prev/Next buttons. Each page shows 5 redeemed codes; the buttons' custom IDs encode the invoking user's Discord ID so only they can paginate, with a dedicated InteractionCreate listener in bot.ts handling the button events.

Changes:

  • Add getRedeemedCodeCount() and an offset parameter to getRedeemedCodeDetails() in codeManager.
  • Refactor /codes into a reusable buildCodesPage() producing an embed plus Prev/Next button row; also corrects the status emoji key from expired to code expired and trims the public badge text.
  • Register a new button-interaction listener in bot.ts that validates ownership and re-renders the requested page; mark the item complete in IDEAS/TODO.md.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/bot/database/codeManager.ts Adds count query and offset parameter to support pagination.
src/bot/database/codeManager.test.ts New tests covering limit, offset, and count behavior.
src/bot/commands/codes.ts Extracts page-building logic, removes count option, adds button row.
src/bot/bot.ts Adds a button interaction listener that dispatches codes: paging events.
IDEAS/TODO.md Marks the paginated /codes item as implemented.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@BigMichi1 BigMichi1 merged commit 86fa59c into main May 17, 2026
13 checks passed
@BigMichi1 BigMichi1 deleted the feat/codes-pagination branch May 17, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants